home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Mathematics / Notebooks / SigProc2.0 / Packages / SignalProcessing / Digital / MDInvZTransform.m < prev    next >
Encoding:
Text File  |  1992-08-18  |  5.4 KB  |  185 lines

  1. (*  :Title:    Supplemental Inverse z-Transform Rule Base  *)
  2.  
  3. (*  :Authors:    Brian Evans, James McClellan  *)
  4.  
  5. (*
  6.     :Summary:    To define those z-transform operations used only
  7.         in multidimensions.  This reduces the amount of
  8.         memory needed to load in the z-transform.
  9.  *)
  10.  
  11. (*  :Context:    SignalProcessing`Digital`InvZTransform`  *)
  12.  
  13. (*  :PackageVersion:  2.7    *)
  14.  
  15. (*
  16.     :Copyright:    Copyright 1989-1991 by Brian L. Evans
  17.         Georgia Tech Research Corporation
  18.  
  19.     Permission to use, copy, modify, and distribute this software
  20.     and its documentation for any purpose and without fee is
  21.     hereby granted, provided that the above copyright notice
  22.     appear in all copies and that both that copyright notice and
  23.     this permission notice appear in supporting documentation,
  24.     and that the name of the Georgia Tech Research Corporation,
  25.     Georgia Tech, or Georgia Institute of Technology not be used
  26.     in advertising or publicity pertaining to distribution of the
  27.     software without specific, written prior permission.  Georgia
  28.     Tech makes no representations about the suitability of this
  29.     software for any purpose.  It is provided "as is" without
  30.     express or implied warranty.
  31.  *)
  32.  
  33. (*  :History:    *)
  34.  
  35. (*  :Keywords:    z-transform, region of convergence    *)
  36.  
  37. (*
  38.     :Source:      Dungeon and Mersereau.  {Multidimensional Signal
  39.         Processing}. 1984.
  40.  *)
  41.  
  42. (*  :Warning:   *)
  43.  
  44. (*  :Mathematica Version:  1.2 or 2.0  *)
  45.  
  46. (*  :Limitation:  *)
  47.  
  48. (*
  49.     :Discussion:  The idea here is to define those z-transform
  50.           operations which would not be used by undergraduates.
  51.           They would be loaded by the z-transform rule base
  52.           when needed.
  53.  *)
  54.  
  55.  
  56. (*  :Functions:      *)
  57.  
  58.  
  59.  
  60. (*  B E G I N     P A C K A G E  *)
  61.  
  62. BeginPackage[ "SignalProcessing`Digital`MDInvZTransform`" ]
  63. EndPackage[]
  64.  
  65. BeginPackage[ "SignalProcessing`Digital`InvZTransform`",
  66.           "SignalProcessing`Digital`ZSupport`",
  67.           "SignalProcessing`Support`TransSupport`",
  68.           "SignalProcessing`Support`ROC`",
  69.           "SignalProcessing`Support`FilterSupport`",
  70.           "SignalProcessing`Support`SigProc`",
  71.           "SignalProcessing`Support`LatticeTheory`",
  72.           "SignalProcessing`Support`SupCode`" ]
  73.  
  74.  
  75. If [ TrueQ[ $VersionNumber >= 2.0 ],
  76.      Off[ General::spell ];
  77.      Off[ General::spell1 ] ];
  78.  
  79.  
  80. Begin[ "`Private`" ]
  81.  
  82. (*  Check for non-separable upsampled relationship between z variables  *)
  83.  
  84. getexponents[ expr_, wlist_ ] :=
  85.     getexponents[ expr, wlist, {} ]
  86. getexponents[ expr_, {}, exponents_ ] :=
  87.     { expr, exponents }
  88. getexponents[ a_. v_^i_., {v_, vrest___}, exponents_ ] :=
  89.     getexponents[ a, {vrest}, Append[exponents, i] ]
  90. getexponents[ x_, {v_, vrest___}, exponents_ ] :=
  91.     getexponents[ x, {vrest}, Append[exponents, 0] ]
  92.  
  93. upsampleSystem[ x_, upvarlist_ ] :=
  94.     UpsampledSystem[x, upvarlist, getexponents]
  95.  
  96. upsampleSystemQ[ x_, upvarlist_ ] :=
  97.     Block [    {upmatrixtrans, zvars},
  98.         {upmatrixtrans, zvars} = upsampleSystem[x, upvarlist];
  99.         TrueQ[ Length[zvars] >= 2 ] &&
  100.         ! SameQ[ResamplingMatrix[upmatrixtrans], False] ]
  101.  
  102.  
  103. (* ROC adjustment object--- prevents having to make z-transform call itself *)
  104.  
  105. Format[ newROC[ invztrans_, rest___ ] ] := invztrans
  106.  
  107. newROC[ f_, {}, {}, {} ] := f
  108. newROC[ myinvz[ f_, z_, n_, rm_, rp_, rest___],
  109.         {z_, zrest___}, rmlist_, rplist_ ] :=
  110.     newROC[ myinvz[f, z, n, First[rmlist], First[rplist], rest],
  111.         {zrest}, Rest[rmlist], Rest[rplist] ]
  112.  
  113.  
  114. resampleROC[zvars_, mat_, zlist_, rmlist_, rplist_] :=
  115.     Block [    {dims, j, pos, poslist, rm, rmsublist, rp, rpsublist},
  116.  
  117.         dims = Length[zvars];
  118.  
  119.         poslist = Map[ First[First[Position[zlist, #]]]&, zvars ];
  120.         rmsublist = rmlist[[poslist]];
  121.         rpsublist = rplist[[poslist]];
  122.         rmsublist =
  123.             Table[ Apply[ Times, rootROC[ rmsublist, mat[[j]] ] ],
  124.                 {j, 1, dims} ];
  125.         rpsublist =
  126.             Table[ Apply[ Times, rootROC[ rpsublist, mat[[j]] ] ],
  127.                 {j, 1, dims} ];
  128.  
  129.         {rm, rp} = {rmlist, rplist};
  130.         For [ j = 1, j <= dims, j++,
  131.               pos = poslist[[j]];
  132.               rm[[pos]] = rmsublist[[j]];
  133.               rp[[pos]] = rpsublist[[j]] ];
  134.  
  135.         {rm, rp} ]
  136.  
  137. resampleDialogue[ f_, fz_, mnew_, zvars_ ] :=
  138.     Block [    {nfun, oldindent},
  139.         If [ dialogueAllFlag,
  140.              Print[ "( after noting that the exponents of " ];
  141.              Print[ "  ", zvars, " in the expression" ];
  142.              Print[ "  ", f ];
  143.              Print[ "  are related by the linear mapping " ];
  144.              Print[ "  ", mnew, " )" ] ];
  145.         If [ ! SameQ[ResamplingMatrix[mnew], True],
  146.              Assuming[ ResamplingMatrix[mnew], dialogueAllFlag ] ];
  147.         fz ]
  148.  
  149. upsampleSetUp[ f_, z_, n_, rm_, rp_, s_, op_, zlist_, rmlist_, rplist_, nlist_ ] :=
  150.         Block [ {invztrans, lnew, lnewtrans, newrm, newrp, nvarsnew, zvarsnew},
  151.         {upmatrixtrans, zvars} = upsampleSystem[f, zlist];
  152.         {lnewtrans, zvarsnew, nvarsnew} =
  153.             ReorderResampling[upmatrixtrans, zvars, zlist, nlist];
  154.         lnew = Transpose[lnewtrans];
  155.         znew = Map[Apply[Times, #]&, Transpose[zlist ^ lnew]];
  156.         fz = f /. ReplaceWith[znew, zlist];
  157.         resampleDialogue[f, fz, lnew, zvarsnew ];
  158.         invztrans = myinvz[fz, z, n, rm, rp, s, op];
  159.         If [ EmptyQ[rmlist] && EmptyQ[rplist],
  160.              Upsample[lnew, nvarsnew][ invztrans ],
  161.              {newrm, newrp} =
  162.             resampleROC[zvarsnew, lnew, zlist, rmlist, rplist];
  163.              dims = Length[zlist];
  164.              pos = First[First[Position[zlist, z]]];
  165.              Upsample[lnew, nvarsnew][
  166.             newROC[ invztrans,
  167.                 Take[zlist, {pos, dims}],
  168.                 Take[newrm, {pos, dims}],
  169.                 Take[newrp, {pos, dims}] ] ] ] ]
  170.  
  171.  
  172. End[]
  173. EndPackage[]
  174.  
  175.  
  176. If [ TrueQ[ $VersionNumber >= 2.0 ],
  177.      On[ General::spell ];
  178.      On[ General::spell1 ] ];
  179.  
  180.  
  181. (*  E N D I N G     M E S S A G E  *)
  182.  
  183. Print["Special multidimensional inverse z-transform rules have been loaded."]
  184. Null
  185.